package com.sgb.kjwl.view.ui.activity.transport;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.AppQuickMenuPopLayout01Binding;
import com.sgb.kjwl.databinding.AppQuickMenuPopLayout02Binding;
import com.sgb.kjwl.databinding.PopwindowAddFleetBinding;
import com.sgb.kjwl.view.widget.transport.QuickMenuPopWindow;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;


/**
 * author:熊丽
 * createDate:2021/10/14 16:19
 * introduce:
 * modifier:xxx
 * modifiyDate:
 * modifiyContent:
 */
public class AddMenuPopWindow extends PopupWindow implements View.OnClickListener{
    private PopwindowAddFleetBinding mBinding;
    //0——其他视角页面  1——货主视角页面
    private int type;
    private Context mContext;
    private MenuClickResult clickResult;

    public AddMenuPopWindow(Context context, int type) {
        super(context);
        this.type = type;
        this.mContext = context;
        init();
    }

    //初始化页面
    private void init() {
        PopViewHolder popViewHolder = PopViewHolder.get(mContext, null, popLayout());
        setContentView(popViewHolder.getPop());
        setFocusable(true);
        setOutsideTouchable(true);
        ColorDrawable dw = new ColorDrawable(0000000);
        this.setBackgroundDrawable(dw);
        setAnimationStyle(com.swgk.core.R.style.popwindow_dropdown);
        setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);

        if (type == 1) {
            mBinding = (PopwindowAddFleetBinding) popViewHolder.getmBinding();
            mBinding.setOnClick(this);
        }
    }

    protected int popLayout() {
            return R.layout.popwindow_add_fleet;
    }

    public MenuClickResult getClickResult() {
        return clickResult;
    }

    public void setClickResult(MenuClickResult clickResult) {
        this.clickResult = clickResult;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.scan_layout:
                dismiss();
                if (clickResult != null)
                    clickResult.onResult(0);
                break;
            case R.id.message_layout:
                dismiss();
                if (clickResult != null)
                    clickResult.onResult(1);
                break;
        }
    }
    public interface MenuClickResult {
        void onResult(int position);
    }
}
